function common()
{
    //Get the screen height and width
    maskHeight  = $(document).height();
    maskWidth   = $(window).width();

    //Get the window height and width
    winH = $(window).height();
    winW = $(window).width();
    
    $('.modal_close a').click(
        function(e)
        {
            e.preventDefault();
            $('.modal_mask').hide();
            $('.modal_content').hide();
            $('.modal_content input').val('');
            $('.modal_content .form_messages ul').html('');
            $('.modal_content .form_messages').hide();
            $('.form_messages ul').html('');
        }
    )
}

function show_modal_mask()
{
    //Set heigth and width to mask to fill up the whole screen
    $('.modal_mask').css({'width' : maskWidth, 'height' : maskHeight, 'opacity' : '0.8'});
    $('.modal_mask').show();
}

function show_modal_dialog(message, timeout)
{
    show_modal_mask();
    
    $('#modal_dialog .modal_message').html(message);
    
    //Set the popup window to center
    $('#modal_dialog').css({'top' :  winH / 2 - $('#modal_dialog').height() /2});
    $('#modal_dialog').css({'left' : winW / 2 - $('#modal_dialog').width() /2});

    $('#modal_dialog').show();
    
    if(timeout > 0)
    {
        setTimeout('hide_modal_dialog()', timeout);
    }
}

function hide_modal_dialog()
{
    $('.modal_mask').hide();
    $('#modal_dialog').hide();
}